'''
Created on May 18, 2011

@author: Steve
'''
import operator

# A slightly efficient superset of primes.
def PrimesPlus():
  yield 2
  yield 3
  i = 5
  while i<20:
    yield i
    if i % 6 == 1:
      i += 2
    i += 2
# Returns a dict d with n = product p ^ d[p]
def GetPrimeDecomp(n):
  d = {}
  primes = PrimesPlus()
  for p in primes:
    while n % p == 0:
      n /= p
      d[p] = d.setdefault(p, 0) + 1
    if n == 1:
      return d
def NumberOfDivisors(n):
  d = GetPrimeDecomp(n)
  powers_plus = map(lambda x: x+1, d.values())
  return reduce(operator.mul, powers_plus, 1)

def getTriangleNumber(n):
    total = 0
    for i in range(0,n+1):
        total=total+i
    return total

if __name__ == "__main__":
    primes = PrimesPlus()
    print primes
    
    for i in primes:
        print i
        
    for i in primes:
        print i